//
//  RewaradTskVC.m
//  MRBang
//
//  Created by 铅笔 on 16/4/20.
//  Copyright © 2016年 杭州易网新科技. All rights reserved.
//

#import "RewaradTskVC.h"
#import "AddBankCardVC.h"//添加银行卡
#import "HelpMeDoHomeVC.h"//帮我办界面
#import "ExtensionInterfacVC.h"//推广界面

@interface RewaradTskVC ()<UITableViewDataSource,UITableViewDelegate>

@property (nonatomic,strong) UITableView *tableView_rewaradTsk;


@end

@implementation RewaradTskVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"奖励任务";
    self.view.backgroundColor = COLOR_EVERYVIEWBG;
    
    [self initWithRewaradTskVCSubviews];
    
}

- (void) viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    self.navigationController.navigationBarHidden = NO;
    self.tabBarController.tabBar.hidden = YES;
}

#pragma mark --- 创建视图界面
- (void) initWithRewaradTskVCSubviews
{
    self.tableView_rewaradTsk = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight-93*PROPORTION_WIDTH-20)];
    [self.view addSubview:self.tableView_rewaradTsk];
    self.tableView_rewaradTsk.dataSource = self;
    self.tableView_rewaradTsk.delegate = self;
    self.tableView_rewaradTsk.showsVerticalScrollIndicator = NO;
    self.tableView_rewaradTsk.separatorStyle =UITableViewCellSeparatorStyleNone;
    self.tableView_rewaradTsk.backgroundColor = COLOR_EVERYVIEWBG;
}

#pragma  mark ----UITableViewDataSource
- (NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 3;
}

- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *cellFillInInformationID = @"cellFillInInformationID";
    
    UITableViewCell *cell_fillInfo = [tableView cellForRowAtIndexPath:indexPath];
    if (cell_fillInfo==nil) {
        cell_fillInfo = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellFillInInformationID];
    }
    
    UIView *view_line = [[UIView alloc] initWithFrame:CGRectMake(27*PROPORTION_WIDTH, 185*PROPORTION_WIDTH-1.0, kScreenWidth, 1.0)];
    [cell_fillInfo.contentView addSubview:view_line];
    view_line.backgroundColor = [BaseViewController colorWithHexString:@"#EEEFF1"];
    
    cell_fillInfo.selectionStyle = UITableViewCellSelectionStyleNone;
    
    NSArray *array_title = @[@"任务一",@"任务二",@"任务三"];
    
    UILabel *label_leftTitle = [[UILabel alloc] initWithFrame:CGRectMake(39*PROPORTION_WIDTH,79*PROPORTION_WIDTH, 158*PROPORTION_WIDTH, 30*PROPORTION_WIDTH)];
    [cell_fillInfo.contentView addSubview:label_leftTitle];
    label_leftTitle.text = array_title[indexPath.row];
    label_leftTitle.font = [UIFont systemFontOfSize:Font_SIZE_30];
    label_leftTitle.textColor = COLOR_TEXT_0;
    
    label_leftTitle.text = array_title[indexPath.row];
    
    
    //button
    UIButton *button_right = [[UIButton alloc] initWithFrame:CGRectMake(kScreenWidth-168*PROPORTION_WIDTH, 58*PROPORTION_WIDTH, 140*PROPORTION_WIDTH, 72*PROPORTION_WIDTH)];
    
    [button_right setTitle:@"去做任务" forState:UIControlStateNormal];
    [button_right setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    
    [button_right.titleLabel setFont:[UIFont systemFontOfSize:22*PROPORTION_WIDTH]];
    button_right.backgroundColor = COLOR_BUTTON;
    button_right.layer.cornerRadius = 3.0;
    button_right.clipsToBounds = YES;
    button_right.enabled = NO;
    
    //UILabel right
    UILabel *label_rightTitle = [[UILabel alloc] initWithFrame:CGRectMake(kScreenWidth-178*PROPORTION_WIDTH,58*PROPORTION_WIDTH, 150*PROPORTION_WIDTH, 72*PROPORTION_WIDTH)];
    label_rightTitle.textAlignment = NSTextAlignmentRight;
    label_rightTitle.font = [UIFont systemFontOfSize:Font_SIZE_24];
    
    if (indexPath.row==0) {
        //任务1  0 未完成 1 已完成
        if ([self.str_rewuFirst intValue]==0)
        {
            [cell_fillInfo.contentView addSubview:button_right];
            
        }
        if ([self.str_rewuFirst intValue]==1)
        {
            [cell_fillInfo.contentView addSubview:label_rightTitle];
            label_rightTitle.text = @"任务已完成";
            label_rightTitle.textColor = COLOR_TEXT_132;
        }
    }

    if (indexPath.row==1) {
       //任务2  0 未完成 1 进行中 2 已完成
        if ([self.str_rewuFirst intValue]==0)
        {
            [cell_fillInfo.contentView addSubview:button_right];
            
        }
        if ([self.str_rewuFirst intValue]==1)
        {
            [cell_fillInfo.contentView addSubview:label_rightTitle];
            label_rightTitle.text = @"进行中";
            label_rightTitle.textColor = COLOR_TEXT_ORANGE;
        }
        if ([self.str_rewuFirst intValue]==2)
        {
            [cell_fillInfo.contentView addSubview:label_rightTitle];
            label_rightTitle.text = @"任务已完成";
            label_rightTitle.textColor = COLOR_TEXT_132;
        }
    }
    if (indexPath.row==2) {
        [cell_fillInfo.contentView addSubview:button_right];
    }
    return cell_fillInfo;
    
}

- (CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 185*PROPORTION_WIDTH;
}

- (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row==0) {
         if ([self.str_rewuFirst intValue]==0)
         {
         
             //添加银行卡界面
             AddBankCardVC *addBankCardView = [[AddBankCardVC alloc] init];
             [self.navigationController pushViewController:addBankCardView animated:YES];
         }
    }
    if (indexPath.row==1) {
        if ([self.str_rewuSecond intValue]==0)
        {
            //帮我办界面
            HelpMeDoHomeVC *helpMeDoneView = [[HelpMeDoHomeVC alloc] init];
            [self.navigationController pushViewController:helpMeDoneView animated:YES];
        }
    }
    if (indexPath.row==2) {
        
//        if (![self.str_ycaptcha isKindOfClass:[NSNull class]]) {
            //推广界面  ycaptcha 这个是推广码 手动生成 二维码
            ExtensionInterfacVC *extensionView = [[ExtensionInterfacVC alloc] init];
            extensionView.str_ycaptchanum = self.str_ycaptchanum;
            extensionView.str_ycaptcha = self.str_ycaptcha;
            [self.navigationController pushViewController:extensionView animated:YES];
//        }
    }

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    
}

@end
